package com.tz.crm.dao.impl;

import com.tz.crm.dao.AddressDao;
import com.tz.crm.entity.Address;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by Meicheng on 2016/12/23.
 */
@Repository
@Transactional
public class AddressDaoImpl extends BaseDaoImpl<Address, String> implements AddressDao {

    /**
     *
     * @param id Customer Id
     * @return
     */
    @SuppressWarnings("unchecked")
    @Override
    public List<Address> getAddressByCustomerId(String id) {
        List<Address> addresses= getSession()
                .createQuery("select a from Address a where a.customer.id =:id").setParameter("id",id).list();
        return addresses;
    }
}
